local game = require "club.threecard.texas"
local Vector3 = CS.UnityEngine.Vector3

local ontable_config = game.pokerlib.core.poker_container_config.new()
ontable_config.hand_poker_class = game.require 'poker_controller.ontable_poker'
ontable_config.ming_poker_class = game.require 'poker_controller.ming_poker'
local ontable_p1 = Vector3(0, 0, 0)
local ontable_p2 = Vector3(20.1, 0, 0)
local ontable_r1 = Vector3(0, 0, 9.68)
local ontable_r2 = Vector3(0, 0, -8.6)
ontable_config.hand_align = function(pokers, root)
    --这里只考虑两张的情况，写死造型就可以了
    for i, poker in ipairs(pokers) do
        poker:set_parent(root, false)
        if i % 2 == 1 then
            poker:set_position(ontable_p1)
            poker.transform.localEulerAngles = ontable_r1
        else
            poker:set_position(ontable_p2)
            poker.transform.localEulerAngles = ontable_r2
        end
    end
end
local ming_p1 = Vector3(-20, 0, 0)
local ming_p2 = Vector3(28, 0, 0)
local ming_r1 = Vector3(0, 0, 4.736)
local ming_r2 = Vector3(0, 0, -8.6)
ontable_config.ming_align = function(pokers, root)
    for i, poker in ipairs(pokers) do
        poker:set_parent(root, false)

        if i % 2 == 1 then
            poker:set_position(ming_p1)
            poker.transform.localEulerAngles = ming_r1
        else
            poker:set_position(ming_p2)
            poker.transform.localEulerAngles = ming_r2
        end
    end
end

local self_config = game.pokerlib.core.poker_container_config.new()
self_config.hand_poker_class = game.require 'poker_controller.self_poker'
local self_p1 = Vector3(-40, 0, 0)
local self_p2 = Vector3(40, 0, 0)
local self_r1 = Vector3(0, 0, 8.4)
local self_r2 = Vector3(0, 0, -5)
self_config.hand_align = function(pokers, root)
    for i, poker in ipairs(pokers) do
        poker:set_parent(root, false)
        if i % 2 == 1 then
            poker:set_position(self_p1)
            poker.transform.localEulerAngles = self_r1
        else
            poker:set_position(self_p2)
            poker.transform.localEulerAngles = self_r2
        end
    end
end

-- 公牌位置， 5张也写死就好了
local public_pos = 
{
    Vector3(-200, 0, 0),
    Vector3(-100, 0, 0),
    Vector3(0, 0, 0),
    Vector3(100, 0, 0),
    Vector3(200, 0, 0)
}
local public_config = game.pokerlib.core.poker_container_config.new()
public_config.hand_poker_class = game.require 'poker_controller.public_poker'
public_config.hand_align = function(pokers, root)
    for i, poker in ipairs(pokers) do
        poker:set_parent(root, false)
        if i > #public_pos then
            return
        end
        poker:set_position(public_pos[i], false)
    end
end

return {
    ontable_config = ontable_config,
    self_config = self_config,
    public_config = public_config
}